﻿var _CSS1200PATH= "css/grid.css";
var _CSS960PATH= "css/grid_960_16_col.css";
var _CSSLINK;

function getCssLink() {
    var links = $('link');
    var linkNum = links.length;
    if (linkNum > 0) {
        links.each(function () {
            var l = $(this);
            var cssMode = l.attr('cssMode');
            if (cssMode != undefined) {
                _CSSLINK = l;
            }
        });
    }
}

function jpInit() {
    getCssLink();
    resizeWindow();
    $(window).resize(function (e) { resizeWindow(); });
    
    $(window).scroll(function () {
    	var scrollSider = $('.cd_scrollSider');
        var validatedOffset = 175;

        var offset = $(window).scrollTop();
		if(offset > validatedOffset) {
			scrollSider.addClass('cd_sticky');
		} else {
			scrollSider.removeClass('cd_sticky');
		}
		
		//if(offset > validatedOffset) {
		//	scrollSider.animate({top:offset-validatedOffset},{duration:200});
		//} else {
		//	scrollSider.animate({top:0});
		//}

    });
}

function resizeWindow() {
    var screenWidth = $(window).width();
    if (screenWidth >= 1200) {
        _CSSLINK.attr('href', _CSS1200PATH);
    } else {
        _CSSLINK.attr('href', _CSS960PATH);
    }
}